<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
<script>
  
  let obj = {
    name: '90-ing',
    get abc() {
      return this.name
    },
    set abc(val){
      // console.log(val);
      this.name = val
    }
  }

  // obj.name = 'success';

  // console.log(obj.name);
  // console.log(obj.abc);
  // console.dir(obj);
  // console.log(obj);

  

  // obj.abc = 4;

  obj.name = 10;

  console.log(obj.abc);

  //改变  name 更改abc,   改变abc 修改 name ,他们俩是相等的



  /* 
      只要进一次get++

      类似于 computed 计算属性

      
  
  */

  let b = 0;
  let obj2 = {
    get a() {
      if (b > 2) {
        b = 2
      }
      return this.a =  ++ b
    }
  }
  
  console.log(obj2.a ==1 && obj2.a == 2);   //true 


  
  
  
  
  

</script>
</body>
</html>